
             
/**
 * 
 *
 * Copyright (c) 2012-2013 JLLT Corp. 2012-2013,All Rights Reserved.
 * This software is published under the 金麟龙腾商贸有限公司.
 * License version 1.0, a copy of which has been included with this
 * distribution in the LICENSE.txt file. 
 *
 * @File name:  QueryTProductByKeywordByPagerAction.java   根据条件分页查询【商品信息:T_PRODUCT】
 * @Create on:  2012-07-30 21:04:661
 * @Author      :  高宇舟
 *
 * @ChangeList
 * ---------------------------------------------------
 * Date         Editor              ChangeReasons
 *
 */
           
        package com.boho.ecp.product.action;

            
import java.sql.Connection;

import cn.boho.framework.actions.ActionImp;
import cn.boho.framework.context.ActionContext;
import cn.boho.framework.po.ComboPager;
import cn.boho.framework.po.Pager;
import cn.boho.framework.service.MessageService;

import com.boho.ecp.product.dao.TProductDao;

public class QueryTProductByKeywordByPagerAction extends ActionImp {
	private Connection con=null;
	private Pager pager=null;
	private int pageSize = 100;
	private int currentPage = 1;
	@Override
	protected void doException(ActionContext atx, Exception ex) {
		atx.setErrorContext("EC_COMMON_1004", MessageService.getMessage("EC_COMMON_1004"),"【商品信息:T_PRODUCT|】" ,ex);
	}
	@Override
	protected int performExecute(ActionContext atx) throws Exception {
		Integer orderBy =  atx.getIntegerValue("ORDER_BY");
		String productKeyword =  atx.getStringValue("PRODUCT_KEYWORD","");
		String categoryName = atx.getStringValue("CATEGORY_NAME","");
		pager = new Pager(pageSize, currentPage);
		ComboPager cp = TProductDao.queryTProductByKeywordByPager(con,pager,orderBy,productKeyword,categoryName);
		//使用缓存
		//ComboPager cp=TProductCache.queryTProductByKeywordByPager(con,pager,isValid,productKeyword);
		atx.setValue("T_PRODUCT", cp);
		return 1;
	}
	@Override
	protected int verifyParameters(ActionContext atx) throws Exception {
		con = atx.getConection();
		if(atx.getStringValue("PAGE_SIZE")!=null&&!atx.getStringValue("PAGE_SIZE").equals("")){
			pageSize = new Integer(atx.getStringValue("PAGE_SIZE"));
		}
		if(atx.getStringValue("CURRENT_PAGE")!=null&&!atx.getStringValue("CURRENT_PAGE").equals("")){
			currentPage = new Integer(atx.getStringValue("CURRENT_PAGE"));
		}
		return 1;
	}
}
